﻿// Copyright (c) 2011, Szymon Malinowski
// http://code.google.com/p/moki/
// 
// Moki is open source software, licensed under the BSD License.
// http://www.opensource.org/licenses/bsd-license.php]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Moki.Core;

namespace Moki
{
    /// <summary>
    /// Creates custom arguments.
    /// </summary>
    public class Arg
    {
        /// <summary>
        /// Creates any argument of given type.
        /// </summary>
        /// <typeparam name="T">Argument type</typeparam>
        /// <returns></returns>
        public static T Any<T>() 
        {
            MatchersBuilder.AddMatcherAtCurrentPosition(new Matcher(arg => arg is T || arg == null));
            return default(T);
        }

        /// <summary>
        /// Creates any not null arguemnt of given type.
        /// </summary>
        /// <typeparam name="T">Argument type</typeparam>
        /// <returns></returns>
        public static T AnyNotNull<T>() 
        {
            MatchersBuilder.AddMatcherAtCurrentPosition(new Matcher(arg => arg is T));
            return default(T);
        }

        /// <summary>
        /// Creates custom argument matches given condtion.
        /// </summary>
        /// <typeparam name="T">Argument type</typeparam>
        /// <param name="matchCondtion"></param>
        /// <returns></returns>
        public static T Matches<T>(Func<T, bool> matchCondtion)
        {
            MatchersBuilder.AddMatcherAtCurrentPosition(new Matcher(new Condition<T>(matchCondtion)));
            return default(T);
        }
    }
}
